<?php

use Illuminate\Database\Migrations\Migration;

class CreateActivityAnswer extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = <<<SQL
        create table dx_activity_answer
        (
            id int unsigned not null auto_increment
                primary key,
            make_uid int unsigned not null comment '做题者',
            ask_uid int unsigned not null  comment '提问者',
            answer int unsigned not null comment '答案',
            result smallint default 0 comment '结果,0不正确,1正确',
            create_time timestamp null default null,
            update_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
        )comment '默契';
SQL;
        if (!DB::statement($sql)) {
            throw new \Exception("failed on execute SQL: [{$sql}]");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        throw new \Exception('downgrade is forbidden');
    }
}
